from django.db import models

# Create your models here.


class Cate(models.Model):
    name = models.CharField(max_length=20)

    class Meta:
        db_table = 'notice_cate'

    def __str__(self):
        return self.name


class Message(models.Model):
    title = models.CharField(max_length=50, verbose_name='公告标题')
    content = models.CharField(max_length=500, verbose_name='公告内容')
    publisher = models.CharField(max_length=20, verbose_name='发布人')
    is_delete = models.BooleanField(default=False, verbose_name='是否删除')
    STATUS = (
        (1, '草稿'),
        (2, '已发布'),
    )
    status = models.IntegerField(choices=STATUS, default=1, verbose_name='状态')
    cate = models.ForeignKey(Cate, on_delete=models.CASCADE, verbose_name='公告分类')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')

    class Meta:
        db_table = 'notice_message'


    def __str__(self):
        return self.title
